Fox's Git Mirrors
Commit 31458c0f563f7938b7a643a9a5e3993ea2deb128
Parents : 7f0bdda
Author : Ahmet Inan <inan@aicodix.de>
Date : 2025-06-14T08:20:28+02:00
added tool to find xorshift parameters
Changes
Diff
diff --git a/tools/xorshift.c b/tools/xorshift.c
new file mode 100644
index 0000000..b87e0e6
--- /dev/null
+++ b/tools/xorshift.c
@@ -0,0 +1,34 @@
+/*
+Exhaustive search of xorshift parameters
+
+Copyright 2025 Ahmet Inan <inan@aicodix.de>
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv) {
+ if (argc != 2)
+ return 1;
+ int bits = atoi(argv[1]);
+ int mask = (1 << bits) - 1;
+ int seed = 1;
+ for (int a = 1; a < bits; ++a) {
+ for (int b = 1; b < bits; ++b) {
+ for (int c = 1; c < bits; ++c) {
+ int good = 1;
+ for (int y = seed, i = mask; good && i; --i) {
+ y ^= y << a;
+ y &= mask;
+ y ^= y >> b;
+ y ^= y << c;
+ y &= mask;
+ good &= (i == 1) == (y == seed);
+ }
+ if (good)
+ printf("%d %d %d\n", a, b, c);
+ }
+ }
+ }
+ return 0;
+}
Served by rngit 1.4.1 - Generated in 0.02s